﻿/*
 * Created by SharpDevelop.
 * User: IEscarro
 * Date: 9/1/2009
 * Time: 12:06 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using Buaya.Model;

namespace Buaya.Gui
{
	/// <summary>
	/// Description of LoanTypeForm.
	/// </summary>
	public partial class LoanTypeForm : BaseForm
	{
		public LoanTypeForm() : this(new LoanType())
		{
			
		}
		
		public LoanTypeForm(LoanType t)
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			Model = t;
		}
		
		protected override void OnModelChanged(EventArgs e)
		{
			base.OnModelChanged(e);
			LoanType t = Model as LoanType;
			textBoxName.Text = t.Name;
			checkBoxInactive.Checked = t.Inactive;
		}
		
		void ButtonOkClick(object sender, EventArgs e)
		{
			LoanType t = Model as LoanType;
			t.Name = textBoxName.Text;
			t.Inactive = checkBoxInactive.Checked;
			SessionFacade.SaveOrUpdateLoanType(t);
			Close();
		}
		
		void ButtonCancelClick(object sender, EventArgs e)
		{
			Close();
		}
	}
}
